#include <stdio.h>
#include "define.h"
extern char macAddr[];
extern char Addr[];
extern char gateway[];
extern char dns[];
extern char mask[];
void myCp(char * dest, char *src, int size);
void ReadConfig()
{
		FILE * fin = fopen("fvckdrcom.conf","rb");
		if (fin)
		{
			fgets(Addr,16,fin);
			fgets(gateway,16,fin);
			fgets(dns,16,fin);
			fgets(mask,16,fin);
			fread(macAddr,sizeof(char),6,fin);
			fclose(fin);
		}
}

ULONG WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
{
	PIP_ADAPTER_INFO a = pAdapterInfo;
	
	if(!a)
	{
		*pOutBufLen = sizeof(IP_ADAPTER_INFO);
		return ERROR_BUFFER_OVERFLOW;
	}
	a->Next = NULL;
	a->ComboIndex = 0;
	strcpy(a->AdapterName,"Fvck Dr.com");
	strcpy(a->Description,"I do can fvck Dr.com Haha");
	
	a->AddressLength = 6;
	myCp((char*)(a->Address),macAddr,6);
	
	a->Index = 0;
	a->Type = MIB_IF_TYPE_ETHERNET;
	a->DhcpEnabled = 1;

	a->GatewayList.Next =NULL;
	strncpy(a->GatewayList.IpAddress.String , gateway, 16);
	strncpy(a->GatewayList.IpMask.String , mask, 16);
	a->GatewayList.Context = 0;
	//Memory leak here, but i don't care

	a->IpAddressList.Next = NULL;
	strncpy(a->IpAddressList.IpAddress.String , Addr, 16);
	strncpy(a->IpAddressList.IpMask.String  ,mask,16);
	a->IpAddressList.Context = 0;
	a->CurrentIpAddress = &(a->IpAddressList);
	return ERROR_SUCCESS;
}

DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo,PULONG pOutBufLen)
{
	if (!pFixedInfo)
	{
		*pOutBufLen = sizeof(FIXED_INFO);
		return ERROR_BUFFER_OVERFLOW;
	}

	PFIXED_INFO t = pFixedInfo;
	
	strncpy(t->DomainName, "Fvck You", 12);
	strncpy(t->HostName, "Fvck You", 12);
	t->DnsServerList.Context= 0;
	t->DnsServerList.Next = NULL;
	strncpy(t->DnsServerList.IpAddress.String ,dns, 16);
	strncpy(t->DnsServerList.IpMask.String , mask , 16);
	t->CurrentDnsServer = &(t->DnsServerList);
	t->NodeType=0;
	t->ScopeId[0]=0;
	t->EnableDns = 0;
	t->EnableProxy = 0;
	t->EnableRouting = 0;
	return ERROR_SUCCESS;
}

void myCp(char * dest, char *src, int size){
	for (int i = 0; i< size; i++)
		dest[i] = src[i];
}
